import 'package:finance_app/src/entities/invite_member_entity.dart';
import 'package:finance_app/src/entities/role_permission_entity.dart';

inviteMemberEntityFromJson(InviteMemberEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['avatar'] != null) {
		data.avatar = json['avatar'].toString();
	}
	if (json['is_pending'] != null) {
		data.isPending = json['is_pending'] is String
				? int.tryParse(json['is_pending'])
				: json['is_pending'].toInt();
	}
	if (json['role'] != null) {
		data.role = RolePermissionEntity().fromJson(json['role']);
	}
	if (json['enabled'] != null) {
		data.enabled = json['enabled'] is String
				? int.tryParse(json['enabled'])
				: json['enabled'].toInt();
	}
	return data;
}

Map<String, dynamic> inviteMemberEntityToJson(InviteMemberEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['avatar'] = entity.avatar;
	data['is_pending'] = entity.isPending;
	data['role'] = entity.role?.toJson();
	data['enabled'] = entity.enabled;
	return data;
}